#include <iostream>
#include <algorithm>
#include <string>
#include <cstdio>
#include <vector>
#include <stack>
#include <queue>
#include <set>
using namespace std;
class Solution
{
public:
    int findNumberOfLIS(vector<int> &nums)
    {
        int mxcnt = 1, ans = 1;
        vector<int> LIS(nums.size(), 1);
        vector<int> dp(nums.size(), 1);
        for (int i = 1; i < nums.size(); ++i)
        {
            for (int j = 0; j < i; ++j)
            {
                if (nums[j] < nums[i])
                    LIS[i] = max(LIS[i], LIS[j] + 1);
            }
            for (int j = 0; j < i; ++j)
            {
                if (nums[j] < nums[i] && LIS[j] + 1 == LIS[i])
                    dp[i] += dp[j];
            }
            if (mxcnt < dp[i])
                mxcnt = dp[i], ans = 1;
            else if (mxcnt == dp[i])
                ans++;
        }
        return ans;
    }
};